﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PostSharp.Aspects;

namespace EBookStore.AOP
{
    [Serializable]
    class TraceExceptionAttribute : OnMethodBoundaryAspect
    {
        // This method is after target methods exit with exception.
        public override void OnException(MethodExecutionArgs args)
        {
            System.Diagnostics.Trace.Unindent();
            System.Diagnostics.Trace.WriteLine(string.Format(
                "[{0}] EXCEPTION [{1}-{2}] with exception {2}.",
                DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss.fff"),
                args.Method.DeclaringType.FullName,
                args.Method.Name,
                args.Exception.GetType().Name));
        }
    }
}
